<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>扫码</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta http-equiv="Cache-Control" content="no-transform">
		<meta name="format-detection" content="telephone=no">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<link rel="stylesheet" href="style/css/basic.css">
		<link rel="stylesheet" href="style/css/dealer.css" />
		<link rel="stylesheet" href="style/css/sales.css" />
		<script type="text/javascript" src="style/plugin/mui/js/mui.min.js"></script>
		<script type="text/javascript" src="style/js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="style/mockjs/dist/mock.js"></script>
		<script type="text/javascript" src="style/js/vue.min.js"></script>
		<script type="text/javascript" src="style/js/vue-resource.js"></script>
		<script type="text/javascript" src="style/js/basic.js"></script>
	</head>
	<body>
		<div id="salesIndex">
		    <div id="header">
				<h1>扫码</h1>
			</div>
			<div class="body" id="refreshContainer">
				<ul class="list">
					<li v-for="(item,index) in agentMsg" @tap="jumpscan(index)" v-if="agentMsg!=''">
						<a href="javascript:;">
							<div class="list_left">
								<img :src="htp+item.head">
							</div>
							<div class="list_right_text">
								<span>{{item.nickname}}</span>
								<span>{{item.phone}}</span>
							</div>
						</a>
					</li>
				</ul>
			</div>	
		</div>
		<!--footer-->
		<div  id="footer">
			<ul class="clearfix">
				<li>
					<a href='sales_index.html' target="_blank"><i class="icon_scan"></i><span class="active_color">扫码</span></a>
				</li>				
				<li>
					<a href="javascript:;" id="hexiao"><i class="icon_verification"></i><span>核销</span></a>
				</li>
				<li>
					<a href='javascript:;' id="jifen1"><i class="icon_integral"></i><span>积分</span></a>
				</li>
				<li>
					<a href='javascript:;' id="saleMy"><i class="icon_my"></i><span>我的</span></a>
				</li>
			</ul>
		</div>
		<script>
			var hexiao=document.getElementById("hexiao");
			var jifen=document.getElementById("jifen1");
			var saleMy=document.getElementById("saleMy");
			hexiao.addEventListener("tap",function(){
				jumpIndex("sales_verification")
			})
			jifen.addEventListener("tap",function(){
				jumpIndex("sales_integral_mall")
			})
			saleMy.addEventListener("tap",function(){
				jumpIndex("sales_my")
			})
			new Vue({
				el:"#salesIndex",
				data:{
					agentMsg:"",
					htp:"",
					ticket:"",
				    sign:""
				},
				methods:{
					jumpscan:function(sIndex){
						openurl_can("sales",this.agentMsg[sIndex].mem_no)
					}
				},
				created:function(){
					this.ticket=localStorage.getItem("tick")
                    this.sign=localStorage.getItem("sig")
				},
				mounted:function(){
					var p=1;
					var that=this;
					that.htp=domain2
					mui.plusReady(function(){
						mui.init({
						  pullRefresh : {
						    container:"#refreshContainer",
						    down : {
						      style:'circle',
						      color:'#2BD009',
						      height:'50px',
						      range:'100px', 
						      offset:'0px',
						      contentdown:null,
						      auto: true,
						      callback :pullrefesh  	      
						    }
						  }
						}); 
					    function pullrefesh(){
							that.$http.post(domain+"/saler/getAgentList?t="+that.ticket+"&sign="+that.sign,{
							      	page:p++,
							      	page_size:2
							      },{emulateJSON:true}).then(
						            function (res) {
						                // 处理成功的结果
						                console.log(res.body)
						                if(res.body.code==1){
						                  if(res.body.data.length==0){
						                	mui.toast("没有更多了")
						                	return false;
						                  }
						                  that.agentMsg=res.body.data;
						                }else{
						                	mui.toast("暂无商品")
						                }
						            },function (res) {
						            // 处理失败的结果
						            console.log(res) 
						            }
						        ).then(function(){
						        	mui('#refreshContainer').pullRefresh().endPulldownToRefresh();   
						        });
						}
			            var first = null;  
			            mui.back=function(){
			            if(!first){  
			                    first = new Date().getTime();  
			                    mui.toast('再按一次退出应用');  
			                    setTimeout(function(){  
			                        first = null;  
			                    },2000);  
			                } else {  
			                    if(new Date().getTime() - first < 2000){  
			                        plus.runtime.quit();
			                        localStorage.removeItem("custInfo");
			                    }  
			                }  
			            }; 
					})
				}
			})
		</script>
	</body>
</html>
